// unix/linux headers
#include <unistd.h>

// standard c/c++ headers
#include <iostream>
using namespace std;

int main(int argc, char** argv)
{
    int opt_char = 0;
    char* opt_arg_str = NULL;
    
    while((opt_char  = getopt(argc, argv, "fpuh:b:c:")) != -1)
    {
        switch(opt_char)
        {
            // file sync
            case 'f':
                cout<<"f is caught"<<endl;
                break;

            // package install
            case 'p':
                cout<<"p is caught"<<endl;
                break;

            // upgrade 
            case 'u':
                cout<<"u is caught"<<endl;
                break;


            // network broadcast address
            case 'b':
                cout<<"b is caught"<<endl;
                opt_arg_str = optarg;
                cout<<"broadcast address:"<< opt_arg_str <<endl;
                break;


            // node list
            case 'h':
                cout<<"h is caught"<<endl;
                opt_arg_str = optarg;
                cout<<"opt_arg_str:" << optarg <<endl;
                break;
            
            // command 
            case 'c':
                cout<<"c is caught"<<endl;
                opt_arg_str = optarg;
                cout<< opt_arg_str <<endl;
                break;
            
            //argument error
            //show error message
            case '?':
                cout<<"argument error caught"<<endl;
                break;
            
            //default handler
            //program will never come here
            default:
                cout<<"none is caught"<<endl;
                break;
        }
    }

    return 0;
}
